/* * When the it recive 1 from the master it will turn OFF the LED if it recive 0 it will turn ON. * Made by Eidha alrashdi and edited * fabacadmy2018 *20/6/2018 * Edited by Danny Vallejo fab academy 27/04/2019 * */ #include// add serial library int rxPin = 1;// the receiver will be in pin 1 int txPin = 0;// the sender will be in pin 0 char val = 'd';// defining that val is equal to 1 SoftwareSerial myserial(rxPin, txPin);// defin the serial and indecate the ports. void setup() { myserial.begin(9600); pinMode(8, OUTPUT);// pin 8 is the LED } void loop() { char chr = myserial.read();// chr equal whatever the serial read from the master if (chr == val) {// here I'm saying if the serial read a valuy equal to what val is, turn LED ON and send that it receive digitalWrite(8, HIGH); myserial.write("atmega_receive");// slave 2 confirming reciving from master. delay(500);// I made it half second to see the process also less than the other slave to not send to the master at the same time. } else { digitalWrite(8, LOW);// if it didnt receive 0 so it will turn ON LED } }